import Vue from "vue";
import VueRouter from "vue-router";
import _router from "../common/_router";


Vue.use(VueRouter)


//固定路由
const routers = [

    //不需要令牌
  _router._register_rule('/notice/success'),
  _router._register_rule('/notice/error'),
  _router._register_rule('/register'),
  _router._register_rule('/register_sale'),
  _router._register_rule('/test'),

    //需要令牌 总部
  _router._register_rule('/manage/index'),
  _router._register_rule('/manage/user'),
  _router._register_rule('/manage/business'),
  _router._register_rule('/manage/activity'),
  _router._register_rule('/manage/activity_info'),
  _router._register_rule('/manage/result'),
  _router._register_rule('/manage/apply'),
  _router._register_rule('/manage/order'),

  // 销售
  _router._register_rule('/business/index'),
  _router._register_rule('/business/achievement'), // 业绩

  //
  _router._register_rule('/page/common'),
  _router._register_rule('/page/success'),

  _router._register_rule_404(),
];


const router = new VueRouter({ mode: 'history', routes: routers })

//重置路由
router.reload_router = function () {
  const new_router = new VueRouter({ mode: 'history', routes: routers })
  router.matcher = new_router.matcher
}

//路由拦截器
router.beforeEach(function (to, from, next) {

  //继续
  next();
});


export default router
